package project02.view;

import project02.domain.CurrentUser;
import project02.service.UserListService;

import java.io.IOException;
import java.text.ParseException;

public class IndexView {

    private static LoginView lv = new LoginView();
    private static NameListView nlv = new NameListView();
   // private static TeamView tv = new TeamView();
    private static JobView jv = new JobView();
    /*
      颜色特效
     */
    public static final String ANSI_RESET = "\u001B[0m";
    public static final String ANSI_BLUE = "\u001B[34m";
    {
        try {
            UserListService.myLoad();
            UserListService.myStore();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) throws IOException, ClassNotFoundException, ParseException, InterruptedException {
       /* String str = "stu01";
        System.out.println(str.startsWith("stu"));
        if(str.startsWith("stu")){
            ...
        }else if(){
            ....
        }*/

        IndexView iv = new IndexView();
        lv.initMenu();
        //iv.softwareMainMenu();
    }

    //软件主菜单
    public static void softwareMainMenu() throws IOException, ClassNotFoundException, ParseException, InterruptedException {

        while (true) {
            System.out.println(ANSI_RESET + ANSI_BLUE);
            System.out.println("🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣");
            System.out.println("🔣                                   🔣");
            System.out.println("🔣             ~用户中心~             🔣");
            System.out.println("🔣                                   🔣");
            System.out.println("🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣🔣");
            System.out.println("🐻1. <个人信息管理>                   *");
            System.out.println("🐘2. <用户管理（仅管理员权限）>        *");
            System.out.println("🐻3. <兼职申请与管理>                 *");
            System.out.println("🦊4. <退出软件>                      **");
            System.out.println("⬇请选择：  ");
            System.out.print(ANSI_RESET);
            switch (TSUtility.readMenuSelectionPro()) {
                case '1':
                    lv.modifyMenu();
                    break;
                case '2':
                    String str="tea";
                    if (CurrentUser.currentUser.getUid().startsWith(str)){
                        try {
                            TSUtility.loadSpecialEffects();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }

                        nlv.DeveloperManageMainMenu();

                    }else {
                        System.out.println("您没有该权限！");
                        TSUtility.loadSpecialEffects();

                    }

                    break;

                case '3':
                    jv.projectManageMainMenu();
                    break;
                case '4':
                    System.out.print("确认是否退出(Y/N)：");
                    if (TSUtility.readConfirmSelection() == 'Y') {
                        System.exit(0);
                    }
                    break;
            }
        }
    }
}
